#include "WorldServerInfo.h"
#include "../Game.h"

WorldServerInfo::WorldServerInfo()
{
	//ctor
	//m_id =
}

WorldServerInfo::~WorldServerInfo()
{
	//dtor
}

void WorldServerInfo::Init()
{
	m_id = std::atoi(Config::globalConfig_map["WorldServerID"].c_str());
	m_name = Config::globalConfig_map["WorldServerName"];
	m_ip = Game::GetInstance().GetSock()->GetIp();
	m_port = Game::GetInstance().GetSock()->GetPort();
	m_count = 0;
	m_State = eServerState::Fine;
	Debug::Log("id:", m_id, " port:", m_port, " name:", m_name);
}

GameServerInfo* WorldServerInfo::GetLoginGameServer()
{
	map<int, GameServerInfo>::iterator Iter = m_GameServerInfo_map.begin();
	for(;Iter != m_GameServerInfo_map.end(); Iter++)
	{
		if((Iter->second).IsCanLogin())
		{
			//return &(Iter->second);
			return &m_GameServerInfo_map[Iter->first];
		}
	}

	return nullptr;
}

bool WorldServerInfo::AddGameServerInfo(const GameServerInfo& _Info)
{
//	Debug::Log("==> WorldServerInfo::AddGameServerInfo");
//	Debug::Log("id: ", _Info.m_id);
	m_GameServerInfo_map[_Info.m_id] = _Info;
//	Debug::Log("==> WorldServerInfo::AddGameServerInfo over");
	return true;
}


